import { FormRule } from 'tdesign-react/es/form/type';
import { PrimaryTableCol } from 'tdesign-react/es/table/type';

// 楼层数据接口
export interface IFloor {
  id: number;
  floorNumber: number;
  description: string;
  createdAt: string;
  updatedAt: string;
}

// 表单数据接口
export interface IFloorForm {
  floorNumber: number;
  description: string;
}

// 组件Props接口
export interface IFloorFormProps {
  visible: boolean;
  onClose: () => void;
  onSuccess: () => void;
}

// 表单验证规则
export const FLOOR_FORM_RULES: Record<string, FormRule[]> = {
  floorNumber: [
    { required: true, message: '请输入楼层号', type: 'error' },
    { pattern: /^\d+$/, message: '楼层号必须为数字', type: 'error' }
  ],
  description: [
    { required: true, message: '请输入描述', type: 'error' }
  ],
};

// 表格列配置
export const FLOOR_TABLE_COLUMNS: PrimaryTableCol<IFloor>[] = [
  {
    title: '楼层号',
    colKey: 'floorNumber',
    width: 200,
    align: 'center',
  },
  {
    title: '描述',
    colKey: 'description',
    align: 'center',
    width: 200,
  },
  {
    title: '创建时间',
    colKey: 'createdAt',
    width: 200,
    align: 'center',
    cell: ({ row }) => new Date(row.createdAt).toLocaleString(),
  },
];

// API响应接口
export interface IApiResponse<T> {
  status: number;
  data: {
    data?: T;
    message?: string;
  };
} 